import { createStore, useStore as baseUseStore, Store } from "vuex";
import { commonRoutes } from "../assets/routers";

import { users } from "./modules/users";

const key = Symbol();

const store = createStore({
  state() {
    return {
      routers: commonRoutes,
    };
  },
  mutations: {},
  actions: {},
  modules: { users },
});

// 将类型注入useStore，项目中引用的均为自定义的这个，覆盖了vuex提供的useStore
export function useStore() {
  return baseUseStore(key);
}

export function setupStore(app) {
  app.use(store, key);
}

export default store;
